package com.lo23.data.objinterface;


import com.lo23.data.objgroup.Friend;
import com.lo23.data.objgroup.Group;
import com.lo23.data.objpicture.Album;
import com.lo23.data.objpicture.Picture;
import com.lo23.data.xml.XMLData;


public class AccessRights {
	

	private XMLData.XMLLocalUser.XMLAccessRights _accessRights;
		
	/**
	 * @param arID
	 * @param name
	 * @param pictureRight
	 * @param commentRight
	 * @param viewCommentRight
	 * @param markRight
	 * @param thePicture
	 * @param theAlbum
	 * @param theGroup
	 * @param theFriend
	 */
	public AccessRights(XMLData.XMLLocalUser.XMLAccessRights accessRights) {
		this._accessRights = accessRights;
	}

//	public AccessRights(String arId) {
//		this._accessRights = new XMLAccessRights(arId);
//	}
//	

//	/**
//	 * @return the profileRight
//	 */
//	public Boolean getProfileRight() {
//		return null;
//	}
//
//	/**
//	 * @param profileRight the profileRight to set
//	 */
//	public void setProfileRight(Boolean profileRight) {
//		_accessRights.setPictureRight(profileRight);
//	}



	/**
	 * Return the status of the picture viewing right
	 * 
	 * @return boolean
	 */
	public Boolean getPictureRight() {
		return (Boolean) _accessRights.isPictureRight();
	}

	/**
	 * Return the status of the comment writing right
	 * 
	 * @return boolean
	 */
	public Boolean getCommentRight() {
		return (Boolean) _accessRights.isCommentRight();
	}

	/**
	 * Return the status of the comment viewing right
	 * 
	 * @return boolean
	 */
	public Boolean getViewCommentRight() {
		return (Boolean) _accessRights.isViewCommentRight();
	}

	/**
	 * Return the status of the marking right
	 * 
	 * @return boolean
	 */
	public Boolean getMarkRight() {
		return (Boolean) _accessRights.isMarkRight();
	}

	/**
	 * Check if the picture exists
	 * 
	 * @param Picture
	 * @return true or false
	 * 
	 */
	public Boolean hasPicture(Picture pic) {
		XMLData.XMLPicture xmlPic;
		xmlPic = (XMLData.XMLPicture) _accessRights.getPID();
		if (xmlPic != null) {
			return (pic.getpID().equals(xmlPic.getPID()));
		} else {
			return false;
		}
	}

	/**
	 * Check if the album exists
	 * 
	 * @param Album
	 * @return true or false
	 * 
	 */
	public Boolean hasAlbum(Album alb) {
		XMLData.XMLAlbum xmlAlb;
		xmlAlb = (XMLData.XMLAlbum) _accessRights.getAID();
		if (xmlAlb != null) {
			return (alb.getaID().equals(xmlAlb.getAID()));
		} else {
			return false;
		}
	}

	/**
	 * Check if the group exists
	 * 
	 * @param Group
	 * @return true or false
	 * 
	 */
	public Boolean hasGroup(Group grp) {
		XMLData.XMLGroup xmlGrp;
		xmlGrp = (XMLData.XMLGroup) _accessRights.getGID();
		if (xmlGrp != null) {
			return (grp.getgID().equals(xmlGrp.getGID()));
		} else {
			return false;
		}
	}

	/**
	 * Check if the friend exists
	 * 
	 * @param Friend
	 * @return true or false
	 * 
	 */
	public Boolean hasFriend(Friend frd) {
		XMLData.XMLUser xmlFriend;
		xmlFriend = (XMLData.XMLUser) _accessRights.getUID();
		if (xmlFriend != null) {
			return (frd.getuID().equals(xmlFriend.getUID()));
		} else {
			return false;
		}
	}



	/**
	 * Set the status on PictureRight
	 * @param Boolean        
	 */
	public void setPictureRight(Boolean pictureRight) {
		_accessRights.setPictureRight(pictureRight);
	}

	/**
	 * Set the status on CommentRight
	 * @param Boolean
	 */
	public void setCommentRight(Boolean commentRight) {
		_accessRights.setCommentRight(commentRight);
	}

	/**
	 * Set the status on ViewCommentRight
	 * @param Boolean
	 */
	public void setViewCommentRight(Boolean viewCommentRight) {
		_accessRights.setViewCommentRight(viewCommentRight);
	}

	/**
	 * Set the status on MarkRight
	 * @param Boolean
	 */
	public void setMarkRight(Boolean markRight) {
		_accessRights.setMarkRight(markRight);
	}

	/**
	 * Bind the access right with the Picture
	 * @param Picture
	 */
	public void setThePicture(Picture thePicture) {
		_accessRights.setPID(thePicture.getXML());
	}

	/**
	 * Bind the access right with the Album
	 * @param Album
	 */
	public void setTheAlbum(Album theAlbum) {
		_accessRights.setAID(theAlbum.getXML());
	}

	/**
	 * Bind the access right with the Group
	 * @param Group
	 */
	public void setTheGroup(Group theGroup) {
		_accessRights.setGID(theGroup.getXML());
	}

	/**
	 * Bind the access right with the Friend user
	 * @param Friend
	 */
	public void setTheFriend(Friend theFriend) {
		_accessRights.setUID(theFriend.getXML());
	}

}
